package weaver.jobs.cese;

import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;
import weaver.soa.workflow.request.RequestInfo;

/**
 * @Title: ecology
 * @Company: 泛微软件
 * @author: weaver.Dusongsong
 * @version: 1.0
 * @CreateDate: 2020-10-30
 * @Description: 定时查询积分低于60分的，扣分日期加上180天。恢复至60分
 * @ModifyLog:
 **/

public class WeaRecoveryIntegralCronJob extends BaseCronJob {
    @Override
    public void execute() {
        BaseBean baseBean = new BaseBean();
        RequestInfo requestInfo = new RequestInfo();
        baseBean.writeLog( "-----------WeaRecoveryIntegralCronJob------------" );
        RecordSet rs = new RecordSet();
        String currentDate = requestInfo.getRequestManager().getCurrentDate();
        String sql = "select id,to_char(to_date(djrq,'yyyy-mm-dd') + 180,'yyyy-mm-dd') as newdate from uf_fybxxx \n" +
                "where fyfsr<60 and djrq <=concat(substr(to_char(sysdate,'yyyy-mm-dd'),0,4),'-12-31')";
        baseBean.writeLog(sql);
        rs.executeQuery( sql );
        int count = 0;
        while (rs.next()) {
            String id = Util.null2String( rs.getString("id"));//人员ID
            String newdate = Util.null2String( rs.getString("newdate"));//新日期
            if(newdate.equals(currentDate)){
               rs.executeUpdate("update uf_fybxxx set ygxyfz='60' where id=?",id);
               count++;
            }
        }
      baseBean.writeLog("更新数据记录数["+count+"]");
    }
}
